package com.zhaozhe.sort;

/**
 * Created by zhaozhe on 2018/3/8.
 */
public class BubbleSort {
    private int[] nums;

    public int[] sort(){
        for (int i = 0; i <= nums.length - 1; i++){
            for (int j = 0; j <= nums.length - 2; j++){
                if (nums[j] > nums[j + 1]){
                    int temp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = temp;
                }
            }
        }
        return nums;
    }

    public static void main(String[] args) {
        BubbleSort bSort = new BubbleSort();
        bSort.nums = new int[]{11, 23, 13, 41, 51, 16, 71, 8};
        int[] result = bSort.sort();
        for(int i=0; i <= result.length - 1 ; i++){
            System.out.println(result[i]);
        }

    }
}
